|
1
|
|
|
/* |
|
2
|
|
|
* Copyright (c) 2017 Cooperativa EITA (eita.org.br) |
|
3
|
|
|
* |
|
4
|
|
|
* @author Vinicius Cubas Brand <[email protected]> |
|
5
|
|
|
* @author Daniel Tygel <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This file is licensed under the Affero General Public License version 3 |
|
8
|
|
|
* or later. |
|
9
|
|
|
* |
|
10
|
|
|
* See the COPYING-README file. |
|
11
|
|
|
* |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
var api = OCA.Circles.api; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
(function() { |
|
17
|
|
|
if (!OCA.Circles) { |
|
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @namespace |
|
20
|
|
|
*/ |
|
21
|
|
|
OCA.Circles = {}; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
OCA.Circles.App = { |
|
25
|
|
|
|
|
26
|
|
|
initFileList: function($el) { |
|
27
|
|
|
if (this._fileList) { |
|
28
|
|
|
return this._fileList; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
this._fileList = new OCA.Circles.FileList( |
|
|
|
|
|
|
32
|
|
|
$el, |
|
33
|
|
|
{ |
|
34
|
|
|
id: 'circles', |
|
35
|
|
|
scrollContainer: $('#app-content'), |
|
36
|
|
|
fileActions: this._createFileActions(), |
|
37
|
|
|
config: OCA.Files.App.getFilesConfig() |
|
38
|
|
|
} |
|
39
|
|
|
); |
|
40
|
|
|
|
|
41
|
|
|
this._fileList.appName = t('circles', 'Circles'); |
|
42
|
|
|
return this._fileList; |
|
43
|
|
|
}, |
|
44
|
|
|
|
|
45
|
|
|
removeFileList: function() { |
|
46
|
|
|
if (this._fileList) { |
|
47
|
|
|
this._fileList.$fileList.empty(); |
|
48
|
|
|
} |
|
49
|
|
|
}, |
|
50
|
|
|
|
|
51
|
|
|
_createFileActions: function() { |
|
52
|
|
|
// inherit file actions from the files app |
|
53
|
|
|
var fileActions = new OCA.Files.FileActions(); |
|
|
|
|
|
|
54
|
|
|
// note: not merging the legacy actions because legacy apps are not |
|
55
|
|
|
// compatible with the sharing overview and need to be adapted first |
|
56
|
|
|
fileActions.registerDefaultActions(); |
|
57
|
|
|
fileActions.merge(OCA.Files.fileActions); |
|
58
|
|
|
|
|
59
|
|
|
if (!this._globalActionsInitialized) { |
|
60
|
|
|
// in case actions are registered later |
|
61
|
|
|
this._onActionsUpdated = _.bind(this._onActionsUpdated, this); |
|
|
|
|
|
|
62
|
|
|
OCA.Files.fileActions.on('setDefault.app-circles', this._onActionsUpdated); |
|
63
|
|
|
OCA.Files.fileActions.on('registerAction.app-circles', this._onActionsUpdated); |
|
64
|
|
|
this._globalActionsInitialized = true; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
// when the user clicks on a folder, redirect to the corresponding |
|
68
|
|
|
// folder in the files app instead of opening it directly |
|
69
|
|
|
fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { |
|
|
|
|
|
|
70
|
|
|
OCA.Files.App.setActiveView('files', {silent: true}); |
|
|
|
|
|
|
71
|
|
|
OCA.Files.App.fileList.changeDirectory(OC.joinPaths(context.$file.attr('data-path'), filename), true, true); |
|
|
|
|
|
|
72
|
|
|
}); |
|
73
|
|
|
fileActions.setDefault('dir', 'Open'); |
|
74
|
|
|
return fileActions; |
|
75
|
|
|
}, |
|
76
|
|
|
|
|
77
|
|
|
_onActionsUpdated: function(ev) { |
|
78
|
|
|
if (!this._fileList) { |
|
79
|
|
|
return; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
if (ev.action) { |
|
83
|
|
|
this._fileList.fileActions.registerAction(ev.action); |
|
84
|
|
|
} else if (ev.defaultAction) { |
|
85
|
|
|
this._fileList.fileActions.setDefault( |
|
86
|
|
|
ev.defaultAction.mime, |
|
87
|
|
|
ev.defaultAction.name |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
}, |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Destroy the app |
|
94
|
|
|
*/ |
|
95
|
|
|
destroy: function() { |
|
96
|
|
|
OCA.Files.fileActions.off('setDefault.app-circles', this._onActionsUpdated); |
|
|
|
|
|
|
97
|
|
|
OCA.Files.fileActions.off('registerAction.app-circles', this._onActionsUpdated); |
|
98
|
|
|
this.removeFileList(); |
|
99
|
|
|
this._fileList = null; |
|
100
|
|
|
delete this._globalActionsInitialized; |
|
101
|
|
|
} |
|
102
|
|
|
}; |
|
103
|
|
|
|
|
104
|
|
|
})(); |
|
105
|
|
|
|
|
106
|
|
|
$(document).ready(function() { |
|
107
|
|
|
$('#app-content-circlesfilter').on('show', function(e) { |
|
108
|
|
|
OCA.Circles.App.initFileList($(e.target)); |
|
|
|
|
|
|
109
|
|
|
}); |
|
110
|
|
|
$('#app-content-circlesfilter').on('hide', function() { |
|
111
|
|
|
OCA.Circles.App.removeFileList(); |
|
|
|
|
|
|
112
|
|
|
}); |
|
113
|
|
|
}); |
|
114
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.